package com.linh.trade.driver;

import java.util.List;

import com.linh.trade.Operator;
import com.linh.trade.Output;
import com.linh.trade.Trader;
import com.linh.trade.TraderActionLog;
import com.linh.trade.algo.WindowBasedTrendFollower;
import com.linh.trade.algo.Strategy;
import com.linh.trade.algo.TrendFinder;
import com.linh.trade.algo.WindowMoverBySize;
import com.linh.trade.data.MarketDataFromFile;
import com.linh.trade.data.Point;
import com.linh.trade.valuation.Valuator;

public class Driver {
	public static final long NANO_SEC = 1000000000;

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception {

		// load data
		MarketDataFromFile dataReader = new MarketDataFromFile("src/main/resources/techstock_dataset.csv");
		Valuator valuator = new Valuator();
		Operator operator = new Operator(valuator, 500000);
		TrendFinder trendFinder = new TrendFinder(new WindowMoverBySize(6));
		double hurdle = 0.0001 * WindowBasedTrendFollower.HURDLE_UNIT;
		Strategy strategy = new WindowBasedTrendFollower(trendFinder, hurdle);
		Trader trader = new Trader(strategy, operator, valuator, 50000, 5000,
				WindowBasedTrendFollower.HURDLE_UNIT, 0.0001, 0.001);
		trader.addTraderActionListener(new TraderActionLog());
		Output output = new Output("output.txt");
		trader.addTraderActionListener(output);
		dataReader.addListener(trader);
		new Thread(dataReader).start();
		output.close();
	}

}
